package com.huawei.appmarket.framework.fragment;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.text.TextUtils;
import android.widget.HeaderViewListAdapter;
import com.huawei.appgallery.foundation.ui.framework.cardkit.widget.CardListAdapter;
import com.huawei.appgallery.foundation.ui.framework.widget.PullUpListView;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import java.lang.ref.WeakReference;
import o.ccv;
import o.Logger;
import o.ContentManager;
import o.ActivityUtil;
import o.evk;
import o.ll;

public class GiftListFromStoreFragment<T extends SecondaryListFragmentProtocol> extends SecondaryListFragment<T> {
    private e ˊ = new e();

    static class e extends SafeBroadcastReceiver {
        private WeakReference<GiftListFromStoreFragment> ˏ;

        private e(GiftListFromStoreFragment giftListFromStoreFragment) {
            this.ˏ = new WeakReference(giftListFromStoreFragment);
        }

        public void onReceiveMsg(Context context, Intent intent) {
            if (context == null || intent == null || this.ˏ == null) {
                Logger.e("GiftListFromStoreFragment", "onReceive, context = " + context + ", intent = " + intent + ", listFragmentRef = " + this.ˏ);
                return;
            }
            GiftListFromStoreFragment giftListFromStoreFragment = (GiftListFromStoreFragment) this.ˏ.get();
            if (giftListFromStoreFragment == null) {
                Logger.e("GiftListFromStoreFragment", "onReceive, listFragment = null");
                return;
            }
            String action = intent.getAction();
            if (b.ॱ.equals(action) || ccv.ˋ().equals(action)) {
                ˋ(giftListFromStoreFragment);
            } else if ("cardlist_show_toast_action".equals(action)) {
                Object stringExtra = intent.getStringExtra("toast_tips");
                if (!TextUtils.isEmpty(stringExtra) && giftListFromStoreFragment.ᵔ && giftListFromStoreFragment.ᐨॱ) {
                    evk.ˏ();
                    evk.ॱ(stringExtra, 0).ˋ();
                    return;
                }
                Logger.ˎ("GiftListFromStoreFragment", "onReceive, tips: " + stringExtra + ", isSelected = " + giftListFromStoreFragment.ᵔ + ", isOnResumed = " + giftListFromStoreFragment.ᐨॱ);
            }
        }

        private void ˋ(GiftListFromStoreFragment giftListFromStoreFragment) {
            PullUpListView ˏ = giftListFromStoreFragment.ͺˎ;
            if (ˏ != null) {
                CardListAdapter cardListAdapter;
                if (ˏ.getAdapter() instanceof HeaderViewListAdapter) {
                    cardListAdapter = (CardListAdapter) ((HeaderViewListAdapter) ˏ.getAdapter()).getWrappedAdapter();
                } else {
                    cardListAdapter = (CardListAdapter) ˏ.getAdapter();
                }
                if (cardListAdapter != null) {
                    cardListAdapter.notifyDataSetChanged();
                    return;
                }
                return;
            }
            Logger.e("GiftListFromStoreFragment", "onReceive, listView = null");
        }
    }

    public void ˌॱ() {
        super.ˌॱ();
        IntentFilter intentFilter = new IntentFilter(b.ॱ);
        intentFilter.addAction("cardlist_show_toast_action");
        intentFilter.addAction(ccv.ˋ());
        ActivityUtil.registerReceiver(ॱˋ(), intentFilter, this.ˊ);
        ll.ˏ(ContentManager.getInstant().getContext()).ˏ(this.ˊ, intentFilter);
    }

    public void ˋʼ() {
        super.ˋʼ();
        ActivityUtil.unregisterReceiver(ॱˋ(), this.ˊ);
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(this.ˊ);
    }
}
